# coding=utf-8
import os
import shutil

import pytest

from common.Base import allure_report
from config import Conf

if __name__ == "__main__":
    report_path = Conf.get_report_path()
    print("开始删除allure-results")
    filepath = (os.path.abspath(os.path.dirname(__file__)) + "/report/allure-results/")
    if os.path.exists(filepath):
        shutil.rmtree("{}".format(filepath))
        os.makedirs("{}".format(filepath))
    else:
        os.makedirs("{}".format(filepath))
    path_report = (os.path.abspath(os.path.dirname(__file__)) + "/report/allure-report")
    if os.path.exists(path_report):
        shutil.rmtree("{}".format(path_report))
    pytest.main()  # -n=2  多线程执行  --reruns=2 失败重跑  -x用例报错就停止  -k=''包含指定字符串的
    os.system(r"allure generate ./report/allure-results -o ./report/allure-report --clean")
    os.system('allure open report/allure-report')  # 打开报告

